1. Field of the Invention
The present invention generally relates to object-oriented programming (OOP), and in particular to OOP systems supporting the C++ programming language.
2. Background Description
The C++ programming language provides a number of features such as classes, class members, inheritance, multiple inheritance, and virtual inheritance. These object-oriented features have several advantages. Most importantly, they enable the creation of class libraries that can be reused in many different applications. However, such code reuse comes at a price. In order to facilitate reusability, OO programming encourages the design of classes that incorporate a high degree of functionality. Programs that use a class library typically exercise only a part of the library's functionality. Such a program may pay a performance penalty for library functionality that it does not use. This performance penalty may be due to the following reasons.
A library may contain dead executable code. Dead executable code is code that is not executed during any execution of the program, or code whose execution cannot affect the program's observable behavior. Dead executable code in an application adversely affects execution speed (both directly, through execution of redundant code, and indirectly through cache/page effects) and is hence undesirable. Dead executable code may take the form of unused library procedures. Prior art has addressed the problem of eliminating unused functions; an example of such prior art is, e.g., A. Srivastava, "Unused procedures in object-oriented programming", ACM Letters on Programming Languages and Systems, 1(4), pp. 355-364. Other prior art has focused on eliminating dead code at the statement level; see e.g., A. Aho, R. Sethi, and J. D. Ullman, "Compilers, Principles, Techniques, and Tools", Addison-Wesley, 1986, and F. Tip, "A Survey of Program Slicing Techniques", Journal of Programming Languages 3,3, (1995), pp. 121-189.
Objects may contain unnecessary data members and subobjects. Unused members and subobjects within objects have the effect of increasing the space requirements of an application. This may also result in decreased execution speed because creation/destruction of objects may require more time than is necessary (due to the construction/destruction of redundant components in objects), as well as through cache/page effects. Prior art has addressed the elimination of data members and subobjects that are not accessed during any execution of an application; see Tip et al., "Slicing Class Hierarchies in C++", Proceedings of the Eleventh Annual Conference on Object-Oriented Programming, Languages, and Applications (OOPSLA'96), (San Jose, Calif., October 1996), ACM SIGPLAN Notices 31(10), pp. 179-197. However, the prior art does not address situations where a given member is (un)used by some, but not all, instances of a given class.
Class hierarchies may unnecessarily exhibit virtual inheritance. Class hierarchies that represent extendable frameworks may exhibit virtual inheritance. The use of virtual inheritance in a program's class hierarchy increases the time require to access class members, and may increase the size of objects.
Such prior art methods that eliminate virtual inheritance are only capable of eliminating classes, eliminating inheritance relations, and replacing virtual inheritance relations with non-virtual inheritance relations, and are only applicable under certain limited situations.